package com.kmproject.haifu.mvp.ui.adapter;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kmproject.haifu.R;
import com.kmproject.haifu.app.utils.TimeUtils;
import com.kmproject.haifu.mvp.model.entity.beans.RentHouseViewHistoryBean;
import com.kmproject.haifu.mvp.ui.activity.HouseRentShowInfoActivity;

import java.util.ArrayList;
import java.util.List;

public class RentHouseViewHistoryAdapter extends BaseQuickAdapter<RentHouseViewHistoryBean,BaseViewHolder> {
    public RentHouseViewHistoryAdapter(@Nullable List<RentHouseViewHistoryBean> data) {
        super(R.layout.renthouseviewhistory_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RentHouseViewHistoryBean item) {
        if (TimeUtils.getDayAndMonth().equals(item.getViewTime()))
        {
           helper.<TextView>getView(R.id.renthouseviewhistory_item_txt).setText("今天");
        }else {
            helper.<TextView>getView(R.id.renthouseviewhistory_item_txt).setText(item.getViewTime());
        }
        helper.<RecyclerView>getView(R.id.renthouseviewhistory_item_RecyclerView).setLayoutManager(new LinearLayoutManager(mContext));
        NyCollectHouseRentAdapter nyCollectHouseRentAdapter=  new NyCollectHouseRentAdapter(item.getResult());
        helper.<RecyclerView>getView(R.id.renthouseviewhistory_item_RecyclerView).setAdapter(nyCollectHouseRentAdapter);
        nyCollectHouseRentAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Intent intent=new Intent(mContext,HouseRentShowInfoActivity.class);
                intent.putExtra("rentId",nyCollectHouseRentAdapter.getData().get(position).getRentId());
                intent.putExtra("type","publish");
                mContext.startActivity(intent);
            }
        });


    }
}
